﻿using System;
using System.Windows.Forms;

namespace WFCSharp_I
{
    public partial class DemoTreeView : Form
    {
        public DemoTreeView()
        {
            InitializeComponent();
        }

        private void TreeView_Load(object sender, EventArgs e)
        {
            TreeNode node = new TreeNode("Chức vụ");

            node.Nodes.Add("Nhân viên");
            node.Nodes.Add("Trưởng phòng");

            TreeNode node1 = new TreeNode("Quản lý");
            node1.Nodes.Add("Quản lý 1");
            node1.Nodes.Add("Quản lý 2");
            node.Nodes.Add(node1);

            treeView1.Nodes.Add(node);

            node = new TreeNode("Bộ phận");
            node.Nodes.Add("Kinh doanh");
            node.Nodes.Add("Kế toán");
            node.Nodes.Add("Marketing");
            treeView1.Nodes.Add(node);

            plusMinusCheck.Checked = treeView1.ShowPlusMinus;
            rootLineCheck.Checked = treeView1.ShowRootLines;
        }

        private void showItemButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Selected Item : " + treeView1.SelectedNode.Text);
        }

        private void plusMinusCheck_CheckedChanged(object sender, EventArgs e)
        {
            treeView1.ShowPlusMinus = plusMinusCheck.Checked;
        }

        private void rootLineCheck_CheckedChanged(object sender, EventArgs e)
        {
            treeView1.ShowRootLines = rootLineCheck.Checked;
        }

        private void upButton_Click(object sender, EventArgs e)
        {
            progressBar1.Visible = true;
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (progressBar1.Value < 100)
                progressBar1.Value += 5;
            else
            {
                timer1.Stop();
                progressBar1.Value = 0;
                progressBar1.Visible = false;
            }
        }
    }
}